gusucode.com > 支持向量机工具箱 - LIBSVM OSU_SVM LS_SVM源码程序 > 支持向量机工具箱 - LIBSVM OSU_SVM LS_SVM\stprtool\datasets\nmix.m
function [XMix,IMix]=nmix(MI,SIGMA,PP,N) % function [XMix,IMix]=nmix(MI,SIGMA,PP,N) % NMIX generates mixture of the normal distributed random values % which have mean value MI, covariance SIGMA and a priori % probability PP. Number of samples in the mixture is N. % % Input: % MI [DxK] contains K mean vectors which are D-dimensional, % i.e. MI=[mi_1,mi_2,..mi_K]. % SIGMA [Dx(kxD)] contains K covariance D-by-D matrices, % i.e. SIGMA=[sigma_1, sigma_2, ...,sigma_K]. % PP [1xK] contains K real positive numbers their sum is equal to 1. % N [1x1] an integer that determines number of points in the mixture. % % Output: % XMix [DxK] created mixture consisting of K vectors. % IMix [1xK] K integers which determine label (component of given % given mixture) corresponding to given vector. % % Statistical Pattern Recognition Toolbox, Vojtech Franc, Vaclav Hlavac % (c) Czech Technical University Prague, http://cmp.felk.cvut.cz % Written Vojtech Franc (diploma thesis) 02.01.2000 % Modifications % 24. 6.00 V. Hlavac, comments polished. % 17-march-2001, V. Franc, repared % get DIMension and # of classes DIM=size(MI,1); K=size(MI,2); % computes transf. matrixes for each sigma AT=[]; for i=1:K, [A,p]=chol(inv(SIGMA(:,(i-1)*DIM+1:i*DIM))); AT=[AT,inv(A)]; end % roulette pcurr=0; for i=1:K PPD(i)=pcurr+PP(i); pcurr=PPD(i); end % generate mixture IMix=[]; XMix=[]; for i=1:N, % rand. class rclass=rand(1); class=1; while PPD(class) < rclass & class < K, class=class+1; end IMix=[IMix,class]; % store class % random point falling to the current class p(x|c)=N(MI(class),SIGMA(class)) point=AT(:,(class-1)*DIM+1:DIM*class)*randn(DIM,1)+MI(:,class); XMix=[XMix,point]; % store point end